<template>
    <div>
        <van-nav-bar title="分享动态" fixed @click-right="onClickRight">
          <van-icon name="plus" size="20" slot="right"/>
        </van-nav-bar>
        <van-pull-refresh v-model="isLoading" @refresh="onRefresh">
            <div class="content">
            <div v-for="item in shareData" :key="item.id">
                <ShareListCard :data="item" v-if="item.shaier"></ShareListCard>
            </div>
            </div>
        </van-pull-refresh>
    </div>
</template>
<script>
import ShareListCard from '@/components/ShareListCard.vue'
export default {
  name: 'share',
  components: {
    ShareListCard
  },
  data () {
    return {
      shareData: [],
      isLoading: false
    }
  },
  mounted () {
    this.$axios.get('/api/lists/mod/shaitu/related/1').then((result) => {
      // console.log('result :', result)
      this.shareData = result.data
    }).catch((err) => {
      console.log('err :', err)
    })
  },
  methods: {
    onClickRight () {
      this.$root.$router.push('/doshare')
    },
    onRefresh () {
      this.$axios.get('/api/lists/mod/shaitu/related/1').then((result) => {
        this.shareData = result.data
      })
      setTimeout(() => {
        this.$toast('刷新成功')
        this.isLoading = false
        this.count++
      }, 500)
    }
  }
}
</script>
<style scoped>
.content{
    margin-top: 60px;
    margin-bottom: 60px;
}
.content>div{
    margin-bottom: 10px;
}
</style>
